package serverside;

public class FundTransfer extends Transaction{
    Keypad keypad;
    String tmp;
    public FundTransfer(int _cardID, DatabasePack.BankDatabase atmBankDatabase, Screen atmScreen, Keypad atmKeypad){
        super(_cardID, atmBankDatabase, atmScreen);
        keypad = atmKeypad;
    }
    @Override
    public void execute() {
        System.out.println("Transaction::FundTransfer");
        DatabasePack.BankDatabase database = getBankDatabase();
        Screen screen = getScreen();
        
        screen.sendDataToClient("You can transfer.");
        String[] list = ATM.separate(tmp = keypad.getInput());
        System.out.println("Transaction::FundTransfer client sent: " + 
                tmp);
        String result = database.transfer(Integer.parseInt(list[0]), 
                Integer.parseInt(list[1]), getCardID());
        screen.sendDataToClient(result);
        System.out.println("Transaction::FundTransfer result: " + result +
                    "\n");
    }
    
}
